#include "CMainGameScene.h"

USING_NS_CC;

CCScene* CMainGame::scene()
{
    // 'scene' is an autorelease object
    CCScene *scene = CCScene::create();
    
    // 'layer' is an autorelease object
	CMainGame *layer = CMainGame::create();
	
    // add layer as a child to scene
	scene->addChild(layer);
	
    // return the scene
    return scene;
}

// on "init" you need to initialize your instance
bool CMainGame::init()
{
    //////////////////////////////
    // 1. super init first
	if ( !CCLayer::init())
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

    
    
	CCSpriteFrameCache* cache=CCSpriteFrameCache::sharedSpriteFrameCache();
	cache->addSpriteFramesWithFile("character.plist");
	gameBoard=CGrid::init(11,7);
	this->addChild(gameBoard);
	gameBoard->schedule(schedule_selector(CGrid::update,1.0f));
	
    return true;
}


void CMainGame::menuCloseCallback(CCObject* pSender)
{
    CCDirector::sharedDirector()->end();

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    exit(0);
	#endif

}
